<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件管理器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            height: 100%;
            display: flex;
            flex-direction: column;
        }

        .title {
            padding: 30px 0;
            text-align: center;
        }

        .tip {
            text-align: center;
        }

        .sendBtnsBox {
            display: flex;
            align-items: center;
            justify-content: center;
            margin-top: 20px;
        }

        .sendBtn {
            width: 200px;
            height: 50px;
            line-height: 50px;
            border: 1px solid #ccc;
            box-sizing: border-box;
            text-align: center;
            border-radius: 5px;
            overflow: hidden;
            cursor: pointer;
            user-select: none;
        }

        .sendBtn:first-child {
            margin-right: 5px;
        }

        .sendBtn:last-child {
            margin-left: 5px;
        }
    </style>
    <script src="./js/vue.min.js"></script>
    <!-- <script src="./js/eventManage.js"></script> -->
    <script src="./js/event.js"></script>
</head>

<body>
    <div class="app">
        <div class="title">{{title}}</div>
        <div class="tip">{{tip}}</div>
        <div class="sendBtnsBox">
            <div class="sendBtn sendOne" @click="dingyue1">订阅 1</div>
            <div class="sendBtn sendOne" @click="tongzhi1">通知 1</div>
        </div>
    </div>
    <script>
        var app = new Vue({
            el: ".app",
            data: {
                title: "事件管理器测试",
                tip: "请查看控制台的输出",
                event: null
            },
            created() {
                this.init();
            },
            methods: {
                init() {
                },
                dingyue1() {
                    Event.on("testCb1",(res)=>{
                        console.log('---res---',res);
                    });
                    // this.event.onOnce('testOneCb1', this.testOneCb1);

                    console.log('---事件订阅成功---');
                },
                tongzhi1() {
                    Event.emit('testCb1',{test:111});
                    // this.event.emit('testOneCb1');
                },
                testCb1() {
                    console.log('---订阅者1 接收到事件通知---');
                },
                testOneCb1() {
                    console.log('---订阅者1 接收到一次性事件通知---');
                }
            }
        })
    </script>
</body>

</html>